     
    //
    // 
    // 
    // 购物车复选页面
    function carFy() {
        console.log(123);
        $(".cars").css("display", "block");
    }
    $(".cars-btn").click(function () {
        $(".cars").css("display", "none");
    })
    //查询购物车商品，列表展示
    fn();
    async function fn() {
        let pagesize = 10;
        let pagenum = 0;
        let uid = localStorage.getItem('uid');
        let params = { pagesize, pagenum, uid };
        let { data } = await axios.get(proudtListAPI, { params });
        console.log(data);
        let newData = data.data;
        let arr = newData.map((res) =>
            `
        <li>
        <a href="详情页.html?pid=${res.pid}">
            <img src="${res.pimg}" alt="">
            <p>${res.pname}</p> 
            <span>$${res.pprice}</span>
        </a>
      </li>
    `
        )
        $(".con-top").html(arr.join(""));
        fn4()
    }
    //
    // fn4();
    async function fn4() {
        let uid = localStorage.getItem("uid");
        let params = { id: uid };
        let { data } = await axios.get(cartList, { params });
        console.log(data);
        console.log($(".cat").html(data.data.length));
    }
    // 
    // 
    // 
    // 购物车复选页面功能
    carsFn();
    async function carsFn() {
        let uid = localStorage.getItem("uid");
        let params = { id: uid };
        let { data } = await axios.get(cartList, { params });
        let arr = data.data;
        let newArr = arr.map((res) =>
            `
        <li>
            <img src="${res.pimg}" alt="">
            <p>${res.pname}</p>
            <div class="numb">数量：
                <button onclick="carsSub(${res.pid},this)" class="cars-btn1">-</button>
                <input class="cars-ipt" type="text" value="${res.pnum}">
                <button onclick="carsAdd(${res.pid},this)"  class="cars-btn2">+</button>
            </div>
            <span><i>$${res.pprice}</i>
                <button onclick="carsDel(${res.pid},this)" class="cars-btn3">移除</button>
            </span>
            <button class="cars-btn4"><a href="../html/购物车.html">购物车</a></button>
        </li>
        `
        );
        $(".cars-b").html(newArr.join(""));
    };
    //减少商品数量更新列表
    async function carsSub(pid, btn) {
        let ipt = btn.nextElementSibling;
        if (parseInt(ipt.value) == 1) {
        } else {
            console.log(ipt);
            ipt.value = parseInt(ipt.value) - 1;
            //
            let uid = localStorage.getItem("uid");
            console.log(uid);
            let pnum = ipt.value
            console.log(pnum);
            let params = { uid, pid, pnum };
            let { data } = await axios.get(cartUpdate, { params });
            console.log(params);
        };
    };
    // 增加商品数量并更新列表
    async function carsAdd(pid, btn) {
        let ipt = btn.previousElementSibling;
        ipt.value = parseInt(ipt.value) + 1;
        // 
        let uid = localStorage.getItem("uid");
        let pnum = ipt.value;
        console.log(pnum);
        let params = { uid, pid, pnum };
        let { data } = await axios.get(cartUpdate, { params });
    }
    // 删除购物车商品
    carsDel();
    async function carsDel(pid) {
        let uid = localStorage.getItem("uid");
        let params = { uid, pid };
        let { data } = await axios.get(cartDelete, { params })
        console.log(data.msg);
        carsFn();
        fn1();
    }
    //搜索框显示与隐藏
    function seaFn() {
        $(".search").css("display", "block");
    }
    $(".banner").click(function () {
        $(".search").css("display", "none");
    })
    $(".search1").click(function () {
        $(".search").css("display", "none");
    })
    // 
    async function seaFn2() {
        let pagesize = 10;
        let pagenum = 0;
        let uid = localStorage.getItem("uid");
        let params = { pagesize, pagenum, uid };
        let { data } = await axios.get(proudtListAPI, { params });
        let arr = data.data;
        console.log(arr);
        let str = $(".search-ipts").val();
        if (str == "") {
            alert("搜索内容不能为空");
            return;
        }
        let searchArr = arr.filter((v) => v.pname.indexOf(str) != -1);
        console.log(searchArr);
        let resArr2 = searchArr.map(
            (res) => `
        <li>
        <a href="详情页.html?pid=${res.pid}">
        <img src="${res.pimg}" alt="">
        <p>${res.pname.replaceAll(str, `<strong>${str}</strong>`)}</p>
        <span>$${res.pprice}</span>
        </a>
      </li>
            `
        );
        let html = resArr2.join("");
        $(".search-u").html(html);



        $(".search1").css("display", "block");
    }
    $(".search1").click(function () {
        $(".search1").css("display", "none");
    })